package com.controller;

import com.domain.Employee;
import com.dao.EmployeeDao;
import com.server.EmployeeService;
import com.domain.Whour;
import com.dao.WhourDao;
import com.server.WhourService;
import com.domain.Team;
import com.dao.TeamDao;
import com.server.TeamService;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping(value = "/employee")
public class EmployeeController {

    @Resource(name = "employeeService")
    private EmployeeService employeeService;

    @Resource(name = "whourService")
    private WhourService whourService;

    @Resource(name = "teamService")
    private TeamService teamService;

    //通用页面跳转控制器
    @RequestMapping(value="/{formName}")
    public String f(@PathVariable String formName){
        return formName;
    }

    @RequestMapping(value = "/08Employee")
    public String Employee08(){
        return "08Employee";
    }

    @RequestMapping(value = "/09Employee")
    public String Employee09(){
        return "09Employee";
    }

    //员工信息更新
    @RequestMapping(value="/updateEmployee",method=RequestMethod.POST)
    public String UpdateEmployee(@RequestParam("number")String number,@RequestParam("tel")String tel,@RequestParam("email")String email,
                                 @RequestParam("RTX")String RTX, @RequestParam("infoway")Integer infoway,HttpSession session)throws Exception{
        int i=employeeService.updateEmployee(number,tel,email,RTX,infoway);
        if(i>0){
            Employee employee=employeeService.findEmployeeByNumber(number);
            session.setAttribute("employee", employee);
        }
        return "redirect:08Employee";
    }
}
